<template>
	<!-- 隐患台账 -->
	<view class="">
		<u-navbar title="隐患台账" :placeholder="true" leftIconColor="#fff" @rightClick="openPopup" titleStyle="color: #fff" bgColor="#2172FC" :autoBack="true">
			<template #right>
				<u-icon name="hourglass" color="#fff" size="25"></u-icon>
			</template>
		</u-navbar>
	</view>
	<view class="p-10">
		<template v-if="list.length > 0">
			<view class="card" v-for="(item, index) in list" @click="goDetail(item)">
				<view class="flex m-between">
					<view class="name fw">
						{{ item.dataTypeName }}
					</view>
					<view class="grade fw">隐患状态: {{ item.remark }}</view>
				</view>
				<view class="flex m-between m-t-8">
					<view class="post">隐患等级: {{ item.hiddenLevelName }}</view>
					<view class="pro">检查日期: {{ item.checkDate }}</view>
				</view>
				<view class="flex m-between m-t-8">
					检查人:
					<up-text :lines="1" :text="item.inspectUserNames"></up-text>
				</view>
				<view class="flex m-between m-t-8">检查地点: {{ item.riskLocationName }}</view>
			</view>
		</template>
		<u-empty v-else mode="data"></u-empty>
	</view>
	<!-- 筛选popup -->
	<my-popup :show="showPopup" :queryParams="queryParams" :formItem="formData" @close="closePopup" @reset="reset" @submit="submit"></my-popup>
	<u-back-top :scroll-top="scrollTop" top="600"></u-back-top>
</template>
<script setup>
import { reactive, computed } from 'vue';
import { minPageFindHiddenDanger } from '@/api/hidden-danger.js';
import useList from '@/hooks/useList.js';
import Dict from '@/store/dict.js';

let formData = computed(() => {
	return [
		{
			itemType: 'select',
			label: '隐患状态',
			list: [
				{
					dictLabel: '全部',
					dictValue: '-1'
				},
				{
					dictLabel: '未下达',
					dictValue: '1'
				},
				{
					dictLabel: '待整改',
					dictValue: '2'
				},
				{
					dictLabel: '待验收',
					dictValue: '3'
				},
				{
					dictLabel: '待销号',
					dictValue: '4'
				},
				{
					dictLabel: '已销号',
					dictValue: '5'
				},
				{
					dictLabel: '延期待审核',
					dictValue: '6'
				}
			],
			prop: 'state'
		},
		{
			itemType: 'select',
			label: '隐患等级',
			type: 'hidden_danger_level',
			prop: 'hiddenLevel'
		},
		{
			label: '检查类型',
			type: 'hidden_insert_type',
			itemType: 'select',
			prop: 'dataType'
		},
		{
			itemType: 'date',
			type: 'date',
			label: '开始日期',
			prop: 'startTime'
		},
		{
			itemType: 'date',
			type: 'date',
			label: '结束日期',
			prop: 'endTime'
		},
		{
			label: '检查地点',
			itemType: 'select',
			list: checkList.value,
			prop: 'riskLocationId'
		},
		{
			// itemType: 'select',
			// type: 'GETuseList',
			label: '检查人',
			prop: 'inspectUserNames'
		},
		{
			itemType: 'select',
			type: 'GETuseList',
			label: '责任人',
			prop: 'dutyUserId'
		}
	];
});
const dict = Dict();
let queryParams = reactive({
	pageNum: 1,
	pageSize: 10,
	state: -1,
	startTime: '',
	endTime: ''
});
// 跳转详情
const goDetail = (item) => {
	uni.navigateTo({
		url: '/pages/professional/hiddenTrouble/standingBook/detail?data=' + JSON.stringify(item)
	});
};
const { getListData, getCheckPonit, list, checkList, scrollTop, showPopup, openPopup, closePopup, reset, submit } = useList({
	queryParams,
	api: {
		page: minPageFindHiddenDanger
	}
});
// 字典数据
const getDicts = () => {
	dict.GETspecialtyKey();
};
const init = () => {
	getListData();
	getDicts();
	getCheckPonit();
};
init();
</script>
<style lang="scss" scoped></style>
